<template>
  <div class="time-viewer">{{ dateTime }}</div>
</template>

<script>
import { parseTime } from '@/utils'
let timer = null
export default {
  data() {
    return {
      dateTime: ''
    }
  },
  created() {
    this.getTime()
  },
  destroyed() {
    clearInterval(timer)
  },
  methods: {
    getTime() {
      timer = setInterval(() => {
        const time = new Date()
        this.dateTime = parseTime(time)
      }, 500)
    }
  }
}
</script>

<style lang="scss" scoped>
.time-viewer {
  padding: 0 8px;
  font-size: 16px;
  display: flex;
  align-items: center;
  color: #ffffff;
}
</style>
